package javax.activation;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileDataSource implements DataSource {
    private File _file = null;
    private FileTypeMap typeMap = null;

    public FileDataSource(File file) {
        this._file = file;
    }

    public InputStream getInputStream() throws IOException {
        return new FileInputStream(this._file);
    }

    public String getContentType() {
        if (this.typeMap == null) {
            return FileTypeMap.getDefaultFileTypeMap().getContentType(this._file);
        }
        return this.typeMap.getContentType(this._file);
    }

    public String getName() {
        return this._file.getName();
    }
}
